{
 "cells": [
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-06-10T02:51:49.097083Z",
     "start_time": "2025-06-10T02:51:49.093735Z"
    }
   },
   "source": [
    "import numpy as np \n",
    "import pandas as pd \n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "import os \n",
    "os.chdir('F:/安装包/PPD-First-Round-Data-Updated/PPD-First-Round-Data-Update/')"
   ],
   "outputs": [],
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-06-10T02:51:52.743327Z",
     "start_time": "2025-06-10T02:51:51.259779Z"
    }
   },
   "source": [
    "f_train1 = pd.read_csv('Training Set/PPD_Training_Master_GBK_3_1_Training_Set.csv',encoding='gbk')\n",
    "f_train2 = pd.read_csv('Training Set/PPD_Userupdate_Info_3_1_Training_Set.csv',encoding='gbk')\n",
    "f_train3 = pd.read_csv('Training Set/PPD_LogInfo_3_1_Training_Set.csv',encoding='gbk')\n",
    "f_test1 = pd.read_csv('Test Set/PPD_Master_GBK_2_Test_Set.csv',encoding='gb18030')\n",
    "f_test2 = pd.read_csv('Test Set/PPD_Userupdate_Info_2_Test_Set.csv',encoding='gbk')\n",
    "f_test3 = pd.read_csv('Test Set/PPD_LogInfo_2_Test_Set.csv',encoding='gbk')"
   ],
   "outputs": [],
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-06-10T02:51:55.043156Z",
     "start_time": "2025-06-10T02:51:54.863971Z"
    }
   },
   "source": [
    "# 训练集和测试集合并\n",
    "f_train1['sample_status'] = 'train'\n",
    "f_test1['sample_status'] = 'test'\n",
    "df1 = pd.concat([f_train1,f_test1],axis=0).reset_index(drop=True)\n",
    "df2 = pd.concat([f_train2,f_test2],axis=0).reset_index(drop=True)\n",
    "df3 = pd.concat([f_train3,f_test3],axis=0).reset_index(drop=True)"
   ],
   "outputs": [],
   "execution_count": 4
  },
  {
   "cell_type": "code",
   "metadata": {
    "scrolled": true,
    "ExecuteTime": {
     "end_time": "2025-06-10T02:51:57.287653Z",
     "start_time": "2025-06-10T02:51:57.268847Z"
    }
   },
   "source": [
    "df1.head()"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "     Idx  UserInfo_1 UserInfo_2  UserInfo_3 UserInfo_4  WeblogInfo_1  \\\n",
       "0  10001         1.0         深圳         4.0         深圳           NaN   \n",
       "1  10002         1.0         温州         4.0         温州           NaN   \n",
       "2  10003         1.0         宜昌         3.0         宜昌           NaN   \n",
       "3  10006         4.0         南平         1.0         南平           NaN   \n",
       "4  10007         5.0         辽阳         1.0         辽阳           NaN   \n",
       "\n",
       "   WeblogInfo_2  WeblogInfo_3  WeblogInfo_4  WeblogInfo_5  ...  \\\n",
       "0           1.0           NaN           1.0           1.0  ...   \n",
       "1           0.0           NaN           1.0           1.0  ...   \n",
       "2           0.0           NaN           2.0           2.0  ...   \n",
       "3           NaN           NaN           NaN           NaN  ...   \n",
       "4           0.0           NaN           1.0           1.0  ...   \n",
       "\n",
       "   SocialNetwork_11  SocialNetwork_12  SocialNetwork_13  SocialNetwork_14  \\\n",
       "0                -1                 0                 0                 0   \n",
       "1                -1                 0                 0                 0   \n",
       "2                -1                -1                 1                 0   \n",
       "3                -1                -1                 0                 0   \n",
       "4                -1                -1                 0                 0   \n",
       "\n",
       "   SocialNetwork_15  SocialNetwork_16  SocialNetwork_17  target  ListingInfo  \\\n",
       "0                 0                 0                 1     0.0     2014/3/5   \n",
       "1                 0                 0                 2     0.0    2014/2/26   \n",
       "2                 0                 0                 0     0.0    2014/2/28   \n",
       "3                 0                 0                 0     0.0    2014/2/25   \n",
       "4                 0                 0                 0     0.0    2014/2/27   \n",
       "\n",
       "   sample_status  \n",
       "0          train  \n",
       "1          train  \n",
       "2          train  \n",
       "3          train  \n",
       "4          train  \n",
       "\n",
       "[5 rows x 229 columns]"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Idx</th>\n",
       "      <th>UserInfo_1</th>\n",
       "      <th>UserInfo_2</th>\n",
       "      <th>UserInfo_3</th>\n",
       "      <th>UserInfo_4</th>\n",
       "      <th>WeblogInfo_1</th>\n",
       "      <th>WeblogInfo_2</th>\n",
       "      <th>WeblogInfo_3</th>\n",
       "      <th>WeblogInfo_4</th>\n",
       "      <th>WeblogInfo_5</th>\n",
       "      <th>...</th>\n",
       "      <th>SocialNetwork_11</th>\n",
       "      <th>SocialNetwork_12</th>\n",
       "      <th>SocialNetwork_13</th>\n",
       "      <th>SocialNetwork_14</th>\n",
       "      <th>SocialNetwork_15</th>\n",
       "      <th>SocialNetwork_16</th>\n",
       "      <th>SocialNetwork_17</th>\n",
       "      <th>target</th>\n",
       "      <th>ListingInfo</th>\n",
       "      <th>sample_status</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10001</td>\n",
       "      <td>1.0</td>\n",
       "      <td>深圳</td>\n",
       "      <td>4.0</td>\n",
       "      <td>深圳</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2014/3/5</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10002</td>\n",
       "      <td>1.0</td>\n",
       "      <td>温州</td>\n",
       "      <td>4.0</td>\n",
       "      <td>温州</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2014/2/26</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10003</td>\n",
       "      <td>1.0</td>\n",
       "      <td>宜昌</td>\n",
       "      <td>3.0</td>\n",
       "      <td>宜昌</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2014/2/28</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10006</td>\n",
       "      <td>4.0</td>\n",
       "      <td>南平</td>\n",
       "      <td>1.0</td>\n",
       "      <td>南平</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2014/2/25</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10007</td>\n",
       "      <td>5.0</td>\n",
       "      <td>辽阳</td>\n",
       "      <td>1.0</td>\n",
       "      <td>辽阳</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2014/2/27</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 229 columns</p>\n",
       "</div>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 5
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-06-10T02:53:44.832906Z",
     "start_time": "2025-06-10T02:53:39.866043Z"
    }
   },
   "source": [
    "# 保存数据至本地\n",
    "df1.to_csv('./data_input1.csv',encoding='gb18030',index=False)\n",
    "df2.to_csv('./data_input2.csv',encoding='gb18030',index=False)\n",
    "df3.to_csv('./data_input3.csv',encoding='gb18030',index=False)"
   ],
   "outputs": [],
   "execution_count": 7
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
